﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitView;
using YJKRevitStairs.StairsModel.Manage;

namespace YJKRevitStairs.StairsModel
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdCreateMultiRunStairs : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			if (Convert.ToInt32(commandData.Application.Application.VersionNumber) < 2014)
			{
				message = "此功能只在Revit2014及其以上版本可用。";
				return Autodesk.Revit.UI.Result.Failed;
			}
			CmdViewType types = (CmdViewType)11;
			if (SwitchView.SetUsableView(types, commandData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			HideWarningKit @object = new HideWarningKit("delete temp levels");
			commandData.Application.Application.FailuresProcessing += @object.OnFailuresProcessing;
			HideWarningKit object2 = new HideWarningKit("Stairs Automation");
			commandData.Application.Application.FailuresProcessing += object2.OnFailuresProcessing;
			HideWarningKit object3 = new HideWarningKit("change type");
			commandData.Application.Application.FailuresProcessing += object3.OnFailuresProcessing;
			HideWarningKit object4 = new HideWarningKit("Stairs Beam");
			commandData.Application.Application.FailuresProcessing += object4.OnFailuresProcessing;
			HideWarningKit object5 = new HideWarningKit("Delete level");
			commandData.Application.Application.FailuresProcessing += object5.OnFailuresProcessing;
			HideWarningKit object6 = new HideWarningKit("CorrectStairsHeight");
			commandData.Application.Application.FailuresProcessing += object6.OnFailuresProcessing;
			if (!new StairsManager(commandData).AddMultiRunStairs())
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
